'''
Created on 01.06.2013

@author: andi
'''
import pygame, sys,os 
from pygame.locals import *
from dame.Interfaces import Move

class DameUI:
    
    def __init__(self):   

        pygame.init() 
        self.window = pygame.display.set_mode((900, 700))
        
        self.side = 500
        self.startx = 200
        self.starty = 100
        self.color1 = (180,100,40)
        self.color2 = (224,224,224)
        self.colorFigur1 = (255,255,255)
        self.colorFigur2 = (0,0,0)
        self.sidefeld = self.side/5

    def paintAll(self, board):
        self.paintBrett()
        self.paintFiguren(board)

    def paintBrett(self): 
        self.window.fill((255, 255, 255))
        pygame.draw.rect(self.window, self.color1, pygame.Rect(self.startx, self.starty, self.side , self.side))
        # weisse felder zeichnen
        for horizontal in range(0, 5,2):
            for vertical in range(0,5,2):   
                pygame.draw.rect(self.window, self.color2, pygame.Rect(self.startx + (self.sidefeld*vertical), self.starty+(self.sidefeld*horizontal), self.sidefeld , self.sidefeld))
            
        for horizontal in range(1,5,2):
            for vertical in range(1,5,2):   
                pygame.draw.rect(self.window, self.color2, pygame.Rect(self.startx + (self.sidefeld*vertical), self.starty+(self.sidefeld*horizontal), self.sidefeld , self.sidefeld))
            
        pygame.display.flip()
        
    def paintFiguren(self, board):
        
        posFigurX = self.startx + self.sidefeld/2
        posFigurY = self.starty + self.sidefeld/2
        
        for y in range(5):
            for x in range(5):
                if not board[y*5+x] == 0:                    
                    if board[y*5+x]._color == 1:
                        pygame.draw.circle(self.window, self.colorFigur1, (posFigurX+x*self.sidefeld, posFigurY+y*self.sidefeld), self.sidefeld/3)
                    elif board[y*5+x]._color == 2:
                        pygame.draw.circle(self.window, self.colorFigur2, (posFigurX+x*self.sidefeld, posFigurY+y*self.sidefeld), self.sidefeld/3)
        pygame.display.flip()
                    
    
    def getZug(self, spieler):
        return Move(spieler,1,2,2,2,-1,-1)
        
            
            